#include "stack.h"

#define Max 10
#define PATH "./data.txt"
void op_int(void* data)
{
	int* tmp = (int*)data;

	printf("%d ", *tmp);
}
void op_char(void* data)
{
	char* tmp = (char*)data;

	printf("%c", *tmp);
}

int main()
{
	stack_t* stack = NULL;
	stack = stack_create(sizeof(int), Max);

	int i = 0;
	for(; i < Max; i++)
	{
		stack_push(stack, &i);
	}

	stack_travel(stack, op_int);

	putchar(10);

	int tmp = *((int*)stack_pop(stack));

	stack_travel(stack, op_int);

	printf("\n%d\n", tmp);

	printf("top : %d\n", stack->top);
	stack_store(stack, PATH);

	printf("top : %d\n", stack->top);

	stack_destroy(&stack);



	/*stack_t* stack = NULL;

	stack = stack_create(sizeof(char), 20);

	char tmp;

	while(tmp != '\n')
	{
		scanf("%c", &tmp);

		if(tmp == '#')
		{
			stack_pop(stack);
		}
		else if(tmp == '@')
		{
			char tmptmp = '\n';
			stack_push(stack, &tmptmp);
		}
		else
		{	
			stack_push(stack, &tmp);
		}
	}

	stack_travel(stack, op_char);

	stack_destroy(&stack);*/

	stack_t* stack1 = NULL;

	stack1 = stack_load(PATH);

	printf("top1 : %d\n", stack->top);

	stack_travel(stack1, op_int);

	stack_destroy(&stack1);




	return 0;
}






















